package com.gzh.controller;


import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.gzh.entity.Pages;
import com.gzh.entity.Result;
import com.gzh.entity.Stu;
import com.gzh.service.IStuService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.stereotype.Controller;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author gzh
 * @since 2022-05-30
 */
@Controller
@RequestMapping("/stu")
public class StuController {

    @Autowired
    IStuService stuService;

    Logger logger = LoggerFactory.getLogger(getClass());
    @RequestMapping("list")
    public Result list(@RequestBody Pages pages){
        logger.info("列表");
        QueryWrapper<Stu> wrapper = new QueryWrapper<>();
        if(pages.getStuTime1()!=null&&!"".equals(pages.getStuTime1())){
            wrapper.gt("stuTime1",pages.getStuTime1());
        }
        if(pages.getStuTime2()!=null&&!"".equals(pages.getStuTime2())){
            wrapper.lt("stuTime2",pages.getStuTime2());
        }
        Page<Stu> stuPage = new Page<>(pages.getPagenum(), pages.getPagesize());
        Page<Stu> page = stuService.page(stuPage, wrapper);
        return new Result(page);
    }
}
